<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .d1{
            width: 500px;
            height: 500px;background-color: pink;
            border: 2px solid black;
        }
        .d1 div:nth-child(1){
            width: 300px;
            height: 300px;
            background-color: skyblue;
            margin: 600px auto;
        }
    </style>
</head>
<body>

    <div class="d1"><div></div></div>

    <script>
        var d1 = document.querySelector('.d1');
        var d2 = document.querySelector('.d1').children[0];
        d2.addEventListener('click',function(e){
            alert(1);
           
        })

        d1.addEventListener('click',function(){
            alert(2);
        })

        window.addEventListener('keydown',function(e){
           var e = e.keyCode;
           console.log(e);
        })
        

        setTimeout(function(){
            console.log(1);
        },1000)
    </script>
</body>
</html>